package top.stmo.stmoBlog.controller;


import org.apache.logging.log4j.core.config.plugins.PluginValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import top.stmo.stmoBlog.dao.vo.ArtivleVo;
import top.stmo.stmoBlog.dao.vo.CommentVo;
import top.stmo.stmoBlog.service.ArticleService;
import top.stmo.stmoBlog.service.CommentService;

import java.util.List;

@Controller
public class ReadController {

    @Autowired
    private ArticleService articleService;

    @Autowired
    private CommentService commentService;


    @GetMapping("read/{id}")
    public String read(@PathVariable Long id, Model model) {

        ArtivleVo artcileVo = articleService.findArticleById(id);

        List<CommentVo> commentVoList = commentService.findAllComment(id);

        model.addAttribute("commentVoList",commentVoList);

        model.addAttribute("artcileVo",artcileVo);
        return "read";
    }

}
